// pages/my/setting.js
const app = getApp()
Page({

     /**
      * 页面的初始数据
      */
     data: {
          userInfo: {},
          authSetting: {}
     },

     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function(options) {
          let that = this;
          app.login(function(userInfo) {
               that.setData({
                    userInfo: userInfo.data
               });
          });

          //获取设置数据
          wx.getSetting({
               success(res) {

                    that.setData({
                         authSetting: res.authSetting
                    });

                    console.log(res.authSetting);
               }
          })
     },
	//更改设置
	switch1Change:function(e){
		console.log(e);
		var item = e.target.dataset.item;
		var value = e.detail.value;
		//定位
		if (item == 'userLocation' ) {
			wx.getLocation({
				type: 'wgs84',
				success: function (res) {
					var latitude = res.latitude
					var longitude = res.longitude
					var speed = res.speed
					var accuracy = res.accuracy
				}
			})
		} else if (item == 'writePhotosAlbum' && value == true) {
			wx.authorize({ scope: "scope.writePhotosAlbum" })
		} else if (item == 'writePhotosAlbum' && value == false) {
			
		}
	}

})